# Contributor: August Klein <amatcoder@gmail.com>
# Maintainer: August Klein <amatcoder@gmail.com>
pkgname=libtorrent-rasterbar
pkgver=1.2.7
_pkgver=${pkgver//./_}
pkgrel=0
pkgdesc="Feature complete C++ bittorrent implementation"
options="!check" # Tests hang on all arches
url="https://www.rasterbar.com/products/libtorrent"
arch="all"
license="BSD-3-Clause"
depends_dev="boost-dev openssl-dev python3-dev"
makedepends="$depends_dev linux-headers"
subpackages="py3-$pkgname:_py3 $pkgname-static $pkgname-dev"
source="https://github.com/arvidn/libtorrent/releases/download/libtorrent_$_pkgver/libtorrent-rasterbar-$pkgver.tar.gz"

build() {
	local _py3ver=$(python3 -c 'import sys; print("{}{}".format(sys.version_info.major, sys.version_info.minor))')
	PYTHON=/usr/bin/python3 \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--enable-tests \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-python-binding \
		--with-boost-system=boost_python$_py3ver
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

_py3() {
	pkgdesc="Python3 bindings for $pkgname"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/share/cmake/* "$pkgdir"/usr/lib/cmake/
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}

sha512sums="60dfb31b1300b3aa2219227b3a263ba73aedb54a90aa940c117027651779cb972d6e1badf9519f6ad7947233b54df608b829bab34493ceda9e4cb8913041a752  libtorrent-rasterbar-1.2.7.tar.gz"
